home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / reuse.lha / reuse / c / Sets.h < prev    next >
C/C++ Source or Header  |  1992-08-18  |  3KB  |  98 lines

  1. # ifndef yySets
  2. # define yySets
  3.  
  4. /* $Id: Sets.h,v 1.7 1992/08/07 14:36:33 grosch rel $ */
  5.  
  6. /* $Log: Sets.h,v $
  7.  * Revision 1.7  1992/08/07  14:36:33  grosch
  8.  * layout changes
  9.  *
  10.  * Revision 1.6  1992/02/06  09:29:54  grosch
  11.  * fixed bug: stdio and ANSI C
  12.  *
  13.  * Revision 1.5  1991/11/21  14:25:34  grosch
  14.  * new version of RCS on SPARC
  15.  *
  16.  * Revision 1.4  91/07/17  17:23:38  grosch
  17.  * introduced ARGS trick for ANSI compatibility
  18.  * 
  19.  * Revision 1.3  90/07/04  14:34:05  grosch
  20.  * introduced conditional include
  21.  * 
  22.  * Revision 1.2  89/12/08  17:25:03  grosch
  23.  * complete redesign in order to increase efficiency
  24.  * 
  25.  * Revision 1.1  89/01/09  17:29:42  grosch
  26.  * added functions Size, Minimum, and Maximum
  27.  * 
  28.  * Revision 1.0  88/10/04  11:44:45  grosch
  29.  * Initial revision
  30.  * 
  31.  */
  32.  
  33. /* Ich, Doktor Josef Grosch, Informatiker, Sept. 1987 */
  34.  
  35. # include "ratc.h"
  36. # include <stdio.h>
  37.  
  38. # ifdef __STDC__
  39. # define ARGS(parameters)    parameters
  40. # else
  41. # define ARGS(parameters)    ()
  42. # endif
  43.  
  44. # define BitsPerBitset        32
  45. # define LdBitsPerBitset    5
  46. # define MaskBitsPerBitset    0x0000001f
  47.  
  48. # define IsElement(Elmt, Set)        ((int) ((Set)->BitsetPtr [(Elmt) >> LdBitsPerBitset] << ((Elmt) & MaskBitsPerBitset)) < 0)
  49. # define Size(Set)            ((Set)->MaxElmt)
  50. # define Select(Set)            Minimum (Set)
  51. # define IsNotEqual(Set1, Set2)        (! IsEqual (Set1, Set2))
  52. # define IsStrictSubset(Set1, Set2) (IsSubset (Set1, Set2) && IsNotEqual (Set1, Set2))
  53.  
  54. typedef long    BITSET        ;
  55.  
  56. typedef struct    {
  57.       cardinal    MaxElmt        ;
  58.       cardinal    LastBitset    ;
  59.       BITSET *    BitsetPtr    ;
  60.       short    Card        ;
  61.       cardinal    FirstElmt    ;
  62.       cardinal    LastElmt    ;
  63.    } tSet;
  64.  
  65. extern void    MakeSet        ARGS((tSet * Set, cardinal MaxSize));
  66. extern void    ReleaseSet    ARGS((tSet * Set));
  67. extern void    Union        ARGS((tSet * Set1, tSet * Set2));
  68. extern void    Difference    ARGS((tSet * Set1, tSet * Set2));
  69. extern void    Intersection    ARGS((tSet * Set1, tSet * Set2));
  70. extern void    SymDiff        ARGS((tSet * Set1, tSet * Set2));
  71. extern void    Complement    ARGS((tSet * Set));
  72. extern void    Include        ARGS((tSet * Set, cardinal Elmt));
  73. extern void    Exclude        ARGS((tSet * Set, cardinal Elmt));
  74. extern cardinal    Card        ARGS((tSet * Set));
  75. /* extern cardinal    Size        ARGS((tSet * Set)); */
  76. extern cardinal    Minimum        ARGS((tSet * Set));
  77. extern cardinal    Maximum        ARGS((tSet * Set));
  78. /* extern cardinal    Select        ARGS((tSet * Set)); */
  79. extern cardinal    Extract        ARGS((tSet * Set));
  80. extern bool    IsSubset    ARGS((tSet * Set1, tSet * Set2));
  81. /* extern bool    IsStrictSubset    ARGS((tSet * Set1, tSet * Set2)); */
  82. extern bool    IsEqual        ARGS((tSet * Set1, tSet * Set2));
  83. /* extern bool    IsNotEqual    ARGS((tSet * Set1, tSet * Set2)); */
  84. /* extern bool    IsElement    ARGS((cardinal Elmt, tSet * Set)); */
  85. extern bool    IsEmpty        ARGS((tSet * Set));
  86. extern bool    Forall        ARGS((tSet * Set, bool (* Proc) ()));
  87. extern bool    Exists        ARGS((tSet * Set, bool (* Proc) ()));
  88. extern bool    Exists1        ARGS((tSet * Set, bool (* Proc) ()));
  89. extern void    Assign        ARGS((tSet * Set1, tSet * Set2));
  90. extern void    AssignElmt    ARGS((tSet * Set, cardinal Elmt));
  91. extern void    AssignEmpty    ARGS((tSet * Set));
  92. extern void    ForallDo    ARGS((tSet * Set, void (* Proc) ()));
  93. extern void    ReadSet        ARGS((FILE * File, tSet * Set));
  94. extern void    WriteSet    ARGS((FILE * File, tSet * Set));
  95. extern void    InitSets    ();
  96.  
  97. # endif
  98.